<template>
  <div class="page-container">
    <fyh-form :module-path="modelPath" v-model="state.queryForm" @handleChange="getDataList()">
      <template #operation>
        <el-button type="primary" icon="Search" @click="getDataList()">查询</el-button>
        <el-button
          icon="Refresh"
          @click="
            resetData(true, () => {
              state.queryForm.dict = 'js_repository_tag';
            })
          "
          >重置</el-button
        >
        <button class="addBtn-small ml12" @click="openDialog('type')">
          <FolderAdd style="width: 1.1em; height: 1.1em" /> 新增字典类型
        </button>
      </template>
    </fyh-form>
    <right-toolbar>
      <el-button type="primary" icon="Plus" @click="openDialog('add')">新增字典</el-button>
    </right-toolbar>
    <fyh-table
      v-chartLoading="{ loading: state.loading, time: 500 }"
      :data="state.dataList"
      :cell-style="cellFunStyle"
      :header-cell-style="headerCellStyle"
      :row-style="rowStyle"
      :module-path="modelPath"
    >
      <template #operation="scope">
        <!-- 修改信息 -->
        <el-button icon="EditPen" text type="primary" @click="openDialog('update')"> 修改 </el-button>
        <!-- 删除用户 -->
        <el-button icon="Delete" v-auth="'admin'" text type="primary" @click="handleDelete()">删除 </el-button>
      </template>
    </fyh-table>
    <the-pagination @current-change="currentChangeHandle" @size-change="sizeChangeHandle" v-bind="state.pagination" />
    <the-dialog :title="dialogOptions.dialogTitle" width="600px" v-model:visible="dialogOptions.dialogVisible">
      <fyh-form :module-path="modelPath" :fileName="dialogOptions.fileName" v-model="dialogOptions.dialogForm" />
    </the-dialog>
  </div>
</template>

<script setup lang="ts" name="dict-manage">
import theDialog from "@/components/Dialog/index.vue";
import FyhForm from "@/components/FyhComs/FyhForm.vue";
import FyhTable from "@/components/FyhComs/FyhTable.vue";
import { useTable, BasicTableProps } from "@/hooks/tablePage";
import { pageList, handleDict } from "@/api/admin/dictManage";
const modelPath = `views/system/dictManage`;
const dialogOptions = reactive({
  dialogVisible: false,
  dialogTitle: "新增",
  dialogForm: {},
  fileName: "Dialog"
});
const state = reactive<BasicTableProps>({
  queryForm: {
    dict: "js_repository_tag",
    label: ""
  },
  pageList
});
const { getDataList, resetData, tableStyle, currentChangeHandle, sizeChangeHandle } = useTable(state);
const { cellFunStyle, headerCellStyle, rowStyle } = toRefs(tableStyle(8));
const handleDelete = () => {};
const openDialog = (type: string) => {
  dialogOptions.dialogVisible = true;
  return
  let filePath = state.queryForm.dict,
  json = {}
  if (type === "type") {
  } else {
    
  }
  handleDict(json, type === 'type' ? 'add' : type, filePath);
};
</script>
